package com.csf.entity;

import org.springframework.stereotype.Component;

//持有用户信息，相当于将用户信息放入session中

@Component
public class SessionReplace{
//    利用ThreadLocal方法
    ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public void setUser(User user){
        threadLocal.set(user);
    }

    public User getUser(){
         return  threadLocal.get();
    }

   public void Clear(){
        threadLocal.remove();
   }
}
